<script lang="ts" setup>
import { computed, onMounted, onBeforeMount, ref } from 'vue'
import { useUserStore } from '@/store/modules/user'
import AdminDashboard from './admin/index.vue'
import EditorDashboard from './editor/index.vue'
import moment from 'moment'

const times = ref('')
const listdata = ref([])
const num = ref(1)
const getTime = () => {
  times.value = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')
}
getTime()

onMounted(() => {
  setInterval(() => {
    getTime()
  }, 1000)
})

const currentRole = ref('admin')
const roles = computed(() => {
  return useUserStore().roles
})
onBeforeMount(() => {
  if (!roles.value.includes('admin')) {
    currentRole.value = 'editor'
  }
})
</script>

<template>
  <!-- <component :is="currentRole === 'admin' ? AdminDashboard : EditorDashboard" /> -->

  <div>我是{{ times }}</div>
  <div>我是第{{ num }}个</div>

  <button>我是按钮</button>
  <ul>
    <li v-for="item in 100" :key="item">
      {{ item }}
    </li>
  </ul>
</template>
